package com.ldj.tim.server.util;

import java.util.Calendar;

/**
 * @author majinhui
 * @description
 * @create 2024/11/19 16:58
 **/
public class TimestampToWeekdayNumber {
    public static int getWeekdayNumber(long timestamp) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(timestamp);

        // 获取星期几 (周日为1, 周一为2, ..., 周六为7)
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);

        // 调整为周一=1，周日=7的形式
        return (dayOfWeek == Calendar.SUNDAY) ? 7 : dayOfWeek - 1;
    }

}
